<extend name="common:commonNewerTemplate" />
<block name="main_content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html"
				data-original-title="Go to Home"><i class="icon-home"></i> 首页</a>
			<a href="#">业务员管理</a> <a class="current" href="#">新增业务员</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>搜索条件</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							<input type="hidden" name="sale_channel" value="1"/>
							<div class="control-group">
								<label class="control-label">用户名:</label>
								<div class="controls">
									<input type="text" id="sale_name" name="sale_name"><span style="color:red;">*</span>
								</div>
							</div>	
							<div class="control-group">
								<label class="control-label">真实姓名:</label>
								<div class="controls">
									<input type="text" id="sale_real_name" name="sale_real_name"><span style="color:red;">*</span>
								</div>
							</div>			
														
                            <div class="control-group">
								<label class="control-label">密码:</label>
								<div class="controls">
									<input type="password" id="password" name="password"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">手机号码:</label>
								<div class="controls">
									<input type="text" id="sale_mobile" name="sale_mobile"><span style="color:red;">*</span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">大区:</label>
								<div class="controls">
									<input type="text" id="area_name" name="area_name"/><span style="color:red;">*</span>
								</div>
							 </div>
							<div class="control-group">
                                    <label class="control-label">省市区</label>
                                    <input type="hidden" id="temp_province"  name="province_name"  >
                                    <input type="hidden" id="temp_city" name="city_name">   
                                     <input type="hidden" id="temp_district" name="district_name">                               
                                    <div class="controls" >
                                        <select id="ssl_province" name="province_id" style="width:240px;" >
                                        </select>
                                        <select id="ssl_city" name="city_id" style="width:240px;" >
                                        </select>
                                       <select id="ssl_district" name="district_id" style="width:240px;">
                                        </select><span style="color:red;">*</span>
                                    </div>
                                </div>
                                
                                
                            <div class="control-group">
								<label class="control-label">部门:</label>
								<div class="controls">
									<input type="text" id="department" name="department"/>
								</div>
							 </div>
							 <div class="control-group">
								<label class="control-label">职能:</label>
								<div class="controls">
									<input type="text" id="occupation" name="occupation"/>
								</div>
							 </div>
							 
							 <div class="control-group">
								<label class="control-label">级别：</label>
								<div class="controls">
								<select id="sale_level" name="sale_level" style="width:220px;" >
									<option value="100">业务员</option>
									<option value="200">区域经理</option>
									<option value="300">省区经理</option>								
								</select><span style="color:red;">*</span>
								</div>
							</div>
							 <div class="control-group">
								<label class="control-label">负责区域:</label>
								<div class="controls">
									<input type="text" id="resp_area" name="resp_area"/>
								</div>
							 </div>
							 <div class="control-group">
								<label class="control-label">邮箱地址:</label>
								<div class="controls">
									<input type="text" id="email_address" name="email_address" placeholder="可以为空，不为空强校验唯一性"/>
								</div>
							 </div>
							<div class="control-group">
								<label class="control-label">业务员地址:</label>
								<div class="controls">
									<input type="text" id="sale_address" name="sale_address">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">备注:</label>
								<div class="controls">
									<input type="text" id="remark" name="remark">
								</div>
							</div>
							<div class="form-actions">
								<input id="btn_sale_add" type="button" class="btn btn-success" value="添加">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
</div>
</block>

<block name="js_content">
<script type="text/javascript">

$('#btn_sale_add').bind('click',function(){
	
	var province_name = $('#ssl_province').find("option:selected").text();		
	var city_name = $('#ssl_city').find("option:selected").text();
	var district_name= $('#ssl_district').find("option:selected").text();
	var sale_level_name= $('#sale_level').find("option:selected").text();
	
	$('#temp_province').val(province_name);
	$('#temp_city').val(city_name);
	$('#temp_district').val(district_name);
	
	var condition = $("#basic_validate").serialize();
	condition=condition+"&sale_level_name="+sale_level_name;

      $.ajax({
          type: 'post',
          url: '/AjaxService/center/sale/addsale',
          data: condition,
          dataType: 'json',
          async: false,
          success: function (data) {
              if (data.IsSuccess == 0) {
                  alert(data.ErrorMsg);
                  return;
              } else {
                  alert('添加成功');
              }
          },
          error: function (e, err_name, err_text) {

          }
      });
});

$(document).ready(function () {
    CommonPage.InitRegion();
   

    //设置省市区
    if($("#temp_province").val()){
        $('#ssl_province').val($("#temp_province").val());
        $('#ssl_province').trigger('change');
    }
    if($("#temp_city").val()){
        $('#ssl_city').val($("#temp_city").val());
        $('#ssl_city').trigger('change');
    }
    if($("#temp_district").val()){
        $('#ssl_district').val($("#temp_district").val());
        $('#ssl_district').trigger('change');
    } 
});

</script>
</block>